﻿if exists (select * from sysobjects where name like N'%sp_CongTy_Insert%')
	drop proc sp_CongTy_Insert
go
create proc sp_CongTy_Insert
	@MaCongTy varchar(50) = null,
	@TenCongTy nvarchar(255) = null,
	@DiaChi nvarchar(255) = null,
	@DienThoai nvarchar(255) = null,
	@Fax nvarchar(50) = null,
	@Website nvarchar(50) = null,
	@TinhThanh nvarchar(50) = null,
	@QuanHuyen nvarchar(50) = null,
	@GiamDoc nvarchar(50) = null,
	@KeToanTruong nvarchar(50) = null,
	@ThuQuy nvarchar(50) = null,
	@MST varchar(50) = null	, 
	@CoQuanThue nvarchar(100) = null,
	@TaiKhoan varchar(50) = null,
	@NganHang nvarchar(255) = null,
	@MauHD varchar(50) = null,
	@Logo image = null,
	@CreatBy int = null,
	@ModifiedBy int = null,
	@ModifiedOn datetime = null
as
begin 
	if not exists (select * from CongTy where MaCongTy = @MaCongTy)
	begin
		insert into Congty (MaCongTy, TenCongTy, DiaChi, DienThoai, Fax, Website, TinhThanh, QuanHuyen,
			GiamDoc, KeToanTruong, ThuQuy, MST, CoQuanThue, TaiKhoan, NganHang, MauHD, Logo, CreateBy, ModifiedBy, ModifiedOn)
		values (@MaCongTy, @TenCongTy, @DiaChi, @DienThoai, @Fax, @Website, @TinhThanh, @QuanHuyen,
			@GiamDoc, @KeToanTruong, @ThuQuy, @MST, @CoQuanThue, @TaiKhoan, @NganHang, @MauHD, @Logo, @CreatBy, null, null)
	end
end